<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function String(s) {
      // 空格补其头尾占位，避免?为首位字符，并转成数组
      s = (` ${s} `).split('')
      for (let i = 0; i < s.length; i++) {
        if (s[i] === '?') {
          // 传?前后字符，生成随机数
          s[i] = randomChar(s[i - 1], s[i + 1])
        }
      }
      // 转为字符串，过滤空格
      return s.join('').replace(/ /g, '')
    };

    const arr1 = (c1, c2) => {
      let str = 'abcefghijklmnopqrtuvwxyz'
      // 过滤前后字符
      str = str.replace(c1, '')
      str = str.replace(c2, '')
      // 生成0-23以内随机数
      const arr1 = Math.round(Math.random() * 23)
      return str[arr1]
    }
    console.log(String('?sd'))
  </script>
</body>

</html>